package com.chenguo.learn.demo.controller;

import com.chenguo.learn.demo.utils.Result;
import com.chenguo.learn.redis.service.RedisService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @ClassName: SampleController
 * @Author: chenguo
 * @Data: 2018年10月08日 17时11分
 * @Description:
 * @Company: 成都灵奇空间软件
 */
@Controller
public class SampleController {

    @Autowired
    private RedisService redisService;

    @RequestMapping("/redis/get")
    @ResponseBody
    public Result<String> redisGet(String key){
        String value = redisService.get(key, String.class);
        return Result.success(value);
    }

    @RequestMapping("/redis/set")
    @ResponseBody
    public Result<Boolean> redisSet(String key, String value){
        boolean result = redisService.set(key, value);
        return Result.success(result);
    }
}
